
import java.util.StringTokenizer;

class P10116 {

	public static void main(String[] args) {
		String line = readLn();
		while (!line.equals("0 0 0")) {
			StringTokenizer st = new StringTokenizer(line);
			int y = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int s = Integer.parseInt(st.nextToken());
			process(x, y, s);
			line = readLn();
		}
	}

	private static void process(int x, int y, int s) {
		boolean[][] gridB = new boolean[y][x];
		char[][] grid = new char[y][x];
		for (int j = 0; j < y; j++) {
			String line = readLn();
			for (int i = 0; i < x; i++) {
				grid[j][i] = line.charAt(i);
			}
		}
		int xR = s-1;
		int yR = 0;
		int counter = 0;
		try {
			while (!gridB[yR][xR]) {
				gridB[yR][xR] = true;
				int[] whereTo = goTo(xR,yR,grid[yR][xR]);
				xR = whereTo[0];
				yR = whereTo[1];
				counter++;
			}
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println(counter + " step(s) to exit");
			return;
		}
		int total = counter;
		
		counter = 0;
		
		do {
			gridB[yR][xR] = false;
			int[] whereTo = goTo(xR,yR,grid[yR][xR]);
			xR = whereTo[0];
			yR = whereTo[1];
			counter++;
		} while (gridB[yR][xR]);
		
		System.out.println((total - counter) + " step(s) before a loop of " + counter + " step(s)");

	}

	private static int[] goTo(int x, int y, char whereTo) {
		switch (whereTo) {
			case 'N':
				y--;
				break;
			
			case 'S':
				y++;
				break;
			
			case 'E':
				x++;
				break;
			
			case 'W':
				x--;
				break;
		}
		int[] answer = {x,y};
		return answer;
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}